<?php

namespace app\common\model\user;

use think\Model;


class Account extends Model
{
    // 表名
    protected $name = 'user_account';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'platform_text',
        'status_text'
    ];

    // 平台
    const PLATFORM = [
        1 =>'抖音', 2 => '快手', 3 => '微信', 4 => '小红书', 5 => '微博',
    ];

    
    public function getPlatformList()
    {
        return ['1' => __('Platform 1'), '2' => __('Platform 2'), '3' => __('Platform 3'), '4' => __('Platform 4'), '5' => __('Platform 5')];
    }

    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2')];
    }


    public function getPlatformTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['platform']) ? $data['platform'] : '');
        $list = $this->getPlatformList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
